<?php
	
	function getAllStations(){
	
	// Datenbankverbindung aufbauen
	$db = new mysqli('localhost', 'root', '', 'cityguide');
	$db->set_charset("utf8");
	if (mysqli_connect_errno()) {
    	printf("Connect failed: %s\n", mysqli_connect_error());
    	exit();
	}
	
	$query = "SELECT distinct SIGHT.s_id,SIGHT.name FROM SIGHT, CITY, TOUR where TOUR.t_id =  CITY.t_id and Tour.s_id = SIGHT.id and CITY.name = ?";

	if ($stmt = $db->prepare($query)) {
		$stmt->bind_param('s', $_SESSION['selectedCity']); # sind die Parameter die mit ? vordefiniert sind
		$stmt->execute();
    	$stmt->bind_result($id, $sight);
    	
    	while ($row = $stmt->fetch()) {
    		
    		echo $sight;
    		  		
    	}	
    	// Statement schliessen
		$stmt->close();
	}
	// Datenbankverbindung schliesssen
	$db->close();	
}

?>